<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #text{
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div id="text">I Miss You</div>
    <div id="result"></div>
    <script>
        setInterval(() => {
            result.innerHTML = `当前布局视口的宽度: ${document.documentElement.clientWidth} <br>
                            当前布局视口的高度: ${document.documentElement.clientHeight}<br>`;

            //设置
            result.innerHTML += `当前视觉视口的宽度: ${window.visualViewport.width} <br>
                           当前视觉视口的高度: ${window.visualViewport.height}`;
            //设置
            // result.innerHTML += `当前视觉视口的宽度: ${window.innerWidth} <br>
            //                当前视觉视口的高度: ${window.innerWidth}`;
        }, 50)
    </script>
</body>

</html>